import request from './request'
import {PageInfoType, PetType} from './type'

// 获取pet分页信息
export function getPetsApi(pageInfo: PageInfoType, name: string | undefined) {
  return request({
    method: 'get',
    url: `/pets?pageSize=${pageInfo.pageSize}&currentPage=${pageInfo.currentPage}
    &name=${name}`,
  })
}

// create pet
export function addPetApi(pet: PetType) {
  return request({
    method: 'post',
    url: '/pets/new',
    data: {
      pet
    }
  })
}

// del pet by id
export function delPetApi(id: number) {
  return request({
    method: 'get',
    url: `/pets/del?id=${id}`
  })
}

// update pet
export function updatePetApi(pet: PetType) {
  return request({
    method: 'post',
    url: '/pets/update',
    data: {
      pet
    }
  })
}
